package com.db.solr.service.controller;

import com.db.solr.service.common.solr.SolrConfigProperties;
import com.db.solr.service.common.solr.SolrPage;
import com.db.solr.service.common.solr.SolrUtil;
import com.db.solr.service.entity.solr.SolrSpu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杜豪波
 * @description: TODO
 * @date 2019/8/21 14:36
 */
@RequestMapping("/solr")
@RestController
public class SolrController {

    @Autowired
    private SolrConfigProperties solrConfigProperties;

    @RequestMapping("/find/list")
    @ResponseBody
    public Object findBySearch(){
        try {
            SolrUtil solrUtil = new SolrUtil(solrConfigProperties.getSolrHostSpu());
            String querySql = "*";
            SolrPage<SolrSpu> solrPage = new SolrPage<SolrSpu>(1, 10);
            solrPage=solrUtil.searchPage(querySql, SolrSpu.class, null, null, solrPage);
            System.out.println(solrPage);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }


}
